import axios from 'axios'

const baseUrl = 'http://localhost:8080/txmap/ws'
const KEY = '6TKBZ-23KCU-N45VZ-BIXDN-ZCFG2-M3BBU'

const locationUrl = '/location/v1/ip' // ip定位

const geocoderLocationUrl = '/geocoder/v1/?location=' // 逆地址解析（坐标位置描述）

const geocoderAddressUrl = '/geocoder/v1/?address=' // 地址解析（地址转坐标）

export const location = () => {
  return axios.post(baseUrl + locationUrl, {
    key: KEY
  })
}

export const geocoderLocation = location => {
  return axios.get(baseUrl + geocoderLocationUrl + location, {
    params: {
      key: KEY
    }
  })
}

export const geocoderAddress = address => {
  return axios.get(baseUrl + geocoderAddressUrl + address, {
    params: {
      key: KEY
    }
  })
}
